package com.pospi.pai.yunpos.report;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.pospi.pai.yunpos.R;
import com.pospi.pai.yunpos.base.Base2Activity;


import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

public class SaleCateDetailActivity extends Base2Activity {
    @Bind(R.id.item_list)
    ListView item_list;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentLayout(R.layout.activity_goods_report_detail);
        ButterKnife.bind(this);

        setTitle("详情");
        List<CateBillBeen> list = (List<CateBillBeen>) getIntent().getSerializableExtra("data");
        if (list != null) {
            beens = list;
        }
        item_list.setAdapter(new MyAdapter());

    }

    List<CateBillBeen> beens = new ArrayList<>();

    private class MyAdapter extends BaseAdapter {

        @Override
        public int getCount() {
            return beens.size();
        }

        @Override
        public Object getItem(int i) {
            return beens.get(i);
        }

        @Override
        public long getItemId(int i) {
            return i;
        }

        @Override
        public View getView(int i, View view, ViewGroup viewGroup) {
            Holder holder;
            if (view == null) {
                holder = new Holder();
                view = LayoutInflater.from(SaleCateDetailActivity.this).inflate(R.layout.cata_report_detail, null);
                holder.name = view.findViewById(R.id.tv_lbm);
                holder.xsje = view.findViewById(R.id.tv_je);
                holder.xssl = view.findViewById(R.id.tv_sl);
                holder.mle = view.findViewById(R.id.tv_mle);
                holder.mlr = view.findViewById(R.id.tv_mll);
                view.setTag(holder);
            } else {
                holder = (Holder) view.getTag();
            }
            CateBillBeen been = beens.get(i);
            holder.name.setText(been.getCatname());
            holder.xsje.setText(been.getLSJJE());
            holder.xssl.setText(been.getSl());
            holder.mle.setText(been.getMLE());
            holder.mlr.setText(been.getMLL());

            return view;
        }

        class Holder {

            TextView name;
            TextView xsje;
            TextView xssl;
            TextView mle;
            TextView mlr;

        }
    }
}
